package com.lostandfound.service.impl;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lostandfound.dao.PlateDao;
import com.lostandfound.entity.Plate;
import com.lostandfound.service.PlateService;
import com.lostandfound.service.TopicService;

/**  
* 
*  
* @date 2018年3月11日
*/
@Service("plateServicce")
@Transactional
public class PlateServiceImpl implements PlateService {
	
	@Autowired
	private PlateDao plateDao;
	@Autowired
	private TopicService topicService; 

	@Override
	public Serializable save(Plate plate) {
		return plateDao.save(plate);
	}

	@Override
	public void update(Plate plate) {
		plateDao.update(plate);
	}

	@Override
	public void delete(Plate plate) {
		plateDao.delete(plate);
	}

	@Override
	public Plate selectByPrimary(Long id) {
		return plateDao.selectByPrimary(id);
	}
	
	@SuppressWarnings("rawtypes")
	@Override
	public List listPlateByPage(Map<String, Object> pagemap) {
		return plateDao.listPlateByPage(pagemap);
	}

	@Override
	public int Count(Map<String, Object> pagemap) {
		return plateDao.Count(pagemap);
	}

	@SuppressWarnings("rawtypes")
	@Override
	public List getPlateByName(String pname) {
		return plateDao.getPlateByName(pname);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void deletePlateByBranch(Long[] plates) {

		for (Long long1 : plates) {
			topicService.deleteTopicByPlate(long1);//先删除板块下的主贴
		}
		plateDao.deletePlateByBranch(plates);//再删除板块
	}

	@Override
	public List<?> getAllPlate() {
		return plateDao.getAllPlate();
	}

}
